<!--tvm票款差异协查-->
<template>
  <div class="TvmTicketCYXC HuikuiInfo el-card is-always-shadow el-card__body">
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      @close="closed"
      width="80%">
      <div style="line-height: 40px;background-color: #fcf7f7;padding-left: 15px">
        <span>线路：</span><span>{{getLineName(formData.lineCode)}}</span>
        <span style="margin-left: 20px">站点：</span><span>{{getStationName(formData.lineCode,formData.stationCode)}}</span>
        <span style="margin-left: 20px">TVM编号：</span><span>{{formData.tvmOrder}}</span>
        <span style="margin-left: 20px"> 收入日期：</span><span>{{formData.settleTime}}</span>
      </div>
      <avue-form :option="option" v-model="formData" @submit="handleSubmit" class="huikuiForm">
        <template slot-scope="{row}" slot="lineCode">
          <span>{{row.lineCode}}</span>
        </template>
        <template slot-scope="{row}" slot="stationCode">
          <span>{{row.stationCode}}</span>
        </template>
        <template slot-scope="{row}" slot="tvmCode">
          <span>{{row.tvmCode}}</span>
        </template>
        <template slot-scope="{row}" slot="incomeTime">
          <span>{{row.incomeTime}}</span>
        </template>
        <template slot-scope="{row}" slot="diffMoney">
          <span>{{fenExYuangettoFixed(row,'diffMoney')}}</span>
        </template>
        <template slot-scope="{row,done}" slot="menuForm" v-if="showType==3">
          <el-button type="primary" @click="closed">返回</el-button>
        </template>


        <template slot-scope="{row}" slot="cashBoxCode">
          <span>{{row.cashBoxCode}}</span>
        </template>
        <template slot-scope="{row}" slot="cashBoxType">
          <span>{{ getQianxiangType(row.cashBoxType)}}</span>
        </template>
        <template slot-scope="{row}" slot="unloadDisplayMoney">
          <span>{{fenExYuangettoFixed(row,'unloadDisplayMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="replyUnloadDisplayMoney">
          <span>{{fenExYuangettoFixed(row,'replyUnloadDisplayMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="unloadDisplayMoneyDiff">
          <span>{{fenExYuangettoFixed(row,'replyUnloadDisplayMoney')-fenExYuangettoFixed(row,'unloadDisplayMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="actualMoneyReplyActualMoney">
          <span>{{fenExYuangettoFixed(row,'replyActualMoney')-fenExYuangettoFixed(row,'actualMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="lineCode">
          <span>{{row.lineCode}}</span>
        </template>
        <template slot-scope="{row}" slot="supplementMoney">
          <span>{{fenExYuangettoFixed(row,'supplementMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="replySupplementMoney">
          <span>{{fenExYuangettoFixed(row,'replySupplementMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="supplementMoneyreplySupplementMoney">
          <span>{{fenExYuangettoFixed(row,'replySupplementMoney')-fenExYuangettoFixed(row,'supplementMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="handOutMoney">
          <span>{{fenExYuangettoFixed(row,'handOutMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="replyHandOutMoney">
          <span>{{fenExYuangettoFixed(row,'replyHandOutMoney')}}</span>
        </template>
        <template slot-scope="{row}" slot="handOutMoneyreplyHandOutMoney">
          <span>{{ fenExYuangettoFixed(row,'replyHandOutMoney')-fenExYuangettoFixed(row,'handOutMoney')}}</span>
        </template>

      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";
  import {
    cols1,
    getSwAuTvmBoxAmountDifference, updateSwAuTvmBoxAmountDifference
  } from '../../../../../api/subwayRat/TVMRevenueVarianceAudit.TvmChaYiDXC/TvmTicketCYXC'
  import {getTvmTicketCYXCNewList} from "../../../../../api/stationTiecketManager/xianWngCJXXQR/tvmPiaoKuanCY/zhanNeiRYDLCK";
  import {
    clearSelect,
    electromeReasons,
    getQianxiangType,
    qianxiangType,
    selectReasons,
    fenExYuangettoFixed,
    getLineName,
    getStationName
  } from "../../../../../api/subwayRat/commonCheck";
  export default {
    components:{
    },
    data() {
      return {
        dialogVisible:true,
        //1添加，2编辑，3预览
        showType:1,
        formData:{
          dynamic: [],
        },
        option:{}
    }
    },
    created() {
    },
    methods: {
      getLineName,
      getStationName,
      fenExYuangettoFixed,
      getQianxiangType,
      handleSubmit(form,done){
        // delete param.dynamic;
        updateSwAuTvmBoxAmountDifference({ids:this.formData.id}).then(res=>{
          if(res.data.code==0){
            this.$message.success("操作成功！");
            this.closed();
            this.$parent.getList();
            clearSelect(this.$parent.$refs.TvmTicketCYXC)
          }else{
            this.$message.error("操作失败！");
          }
        });
        done();
      },
      recallShow(id,row,showType){
        this.showType=showType;
        Object.assign(this.formData,row);
        this.getOption();
        // this.formData.replyReason=Number(this.formData.replyReason);
        // this.formData.selectReason=Number(this.formData.selectReason);
        // this.formData.kyReplyReason=Number(this.formData.kyReplyReason);
        this.formData={}
        getSwAuTvmBoxAmountDifference({id:row.relationid}).then((res)=>{
          this.formData.dynamic=res.data.data;
          console.log(this.formData)
        }).catch((e)=>{
          this.$message.error("获取数据失败！");
        })
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.isShowDia=false;
      },
      getOption(){
        this.option={
          submitBtn:this.showType!=3,
          emptyBtn:false,
          submitText:'一键替换',
          group:[
            {
              icon:'',
              sortable:true,
              label: '钱箱操作信息回馈',
              // collapse:false,
              prop: 'group1',
              indexLabel:"#",
              column: [{
                label: '',
                prop: 'dynamic',
                type: 'dynamic',
                span:24,
                children: {
                  addBtn:false,
                  delBtn:false,
                  sortable:true,
                  index:false,
                  indexLabel:"#",
                  align: 'center',
                  headerAlign: 'center',
                  column: cols1
                }
              }
              ]
            },
            {
              icon:'',
              label: '原因与备注',
              // collapse:false,
              prop: 'group3',
              column: [{
                label: '归属机电专业回馈差异原因',
                prop: 'replyReason',
                labelWidth:200,
                disabled: this.showType==3,
                type:'select',
                dicData:electromeReasons(),
              },
                {
                  label: '机电专业详细描述',
                  prop: 'replyContent',
                  type: 'textarea',
                  labelWidth:150,
                  disabled: this.showType==3
                },
                {
                  label: '归属机电专业回馈差异原因',
                  prop: 'kyReplyReason',
                  labelWidth:200,
                  disabled: this.showType==3,
                  type:'select',
                  dicData:electromeReasons(),
                },
                {
                  label: '机电专业详细描述',
                  prop: 'kyReplayConent',
                  type: 'textarea',
                  labelWidth:150,
                  disabled: this.showType==3
                },{
                  label: '选择原因',
                  prop: 'selectReason',
                  labelWidth:200,
                  display: (this.formData.diffMoney != 0),
                  disabled: this.showType==3,
                  type:'select',
                  dicData:selectReasons(),
                },
              ]
            }
          ]
        };
        this.isReload=false;
        this.$nextTick(()=>{
          this.isReload=true;
        })
      },
      remoteOpen(param){
        this.showType=3;
        getTvmTicketCYXCNewList({id:param.id}).then((response)=>{
          let data = response.data.data;
          this.recallShow(data[0].id,data[0],3);
          this.dialogVisible=true;
        }).catch(e=>{
          this.$message.error("打开失败");
        });
      }
    },
    mounted() {

    }
  }
</script>
<style lang="scss">
  .TvmTicketCYXC.HuikuiInfo{
    .avue-group[index='3']{
      .el-form-item{
        min-width: 450px;
      }
      .avue-form__row{
        width: 70%;
      }
    }
  }
</style>
